import { request } from 'umi';


const fetchTags = () => {
 return request('/api/tags')
}

export default {
  namespace: 'tags',
  state: {
    tagList: []
  },
  effects: {
    *fetchTags({payload, callback}: any, {put, call}: any) {
      // @ts-ignore
      const response = yield call(fetchTags)
      yield put({
        type: 'setTagsList',
        // type: 'setState',
        // payload: {
        //   state: 'tagList',
        //   value: response || []
        // }
        payload: response || []
      })
      return response
    }
  },

  reducers: {
    setTagsList(state:any, action:any) {
      return {...state, tagList: action.payload}
    }
  }

};
